#include "EatFlower.h"


EatFlower::EatFlower(float posX, float posY, float width, float height, Resources* res, int number, int depth)
:GameObject(posX, posY, width, height, res, number, depth)
{
	_sprite = new Sprite(_resources->Eat, 3, 3, 0.2f);
	_id = ID::ID_EatFlower;

	_vel_x = _acc_x = 0;
	_vel_y = 30;

	_old_rect = _rect;

	_max_y = posY;
	_pos_y -= 50;
	_min_y = posY - height - 20;

	_isStatic = false;
}


EatFlower::~EatFlower()
{
}

void EatFlower::Update(float time, QNode* &Tree)
{
	if (_pos_y > _max_y || _pos_y < _min_y)
		_vel_y *= -1;

	_old_x = _pos_x;
	_old_y = _pos_y;

	_pos_y += _vel_y * time;
	_old_rect = _rect;
	ResetRect();

	_sprite->Next(time);
}

void EatFlower::Render(LPD3DXSPRITE spriteHandler, Viewport* viewport)
{
	_sprite->Render(spriteHandler, _pos_x, _pos_y, false, viewport);
}

void EatFlower::ChangeState(char state)
{

}